package peer.tools;

public class ByteLongSwitch {

	public static long toLong(byte[] b,int offset) { 
		int mask = 0xff;
		int temp = 0;
		int res = 0;
		for (int i = 0; i < 8; i++) {
			res <<= 8;
			temp = b[i+offset] & mask;
			res |= temp;
		}
		return res;
	}

	public static void toByteArray(long num,byte[] b,int offset) {
		   for (int i = 0; i < 8; i++) {
		    b[i+offset] = (byte) (num >>> (56 - i * 8));
		   }
	}

}
